package array;

/**
 * @Author wangtengyu
 * @Date 2019/9/21 3:52 PM
 * @Description 替换空格
 */
public class replaceBlank {

  public static void main(String args[]){
      replaceBlank replaceBlank=new replaceBlank();
      String str="we are family";
      System.out.println(replaceBlank.replaceBlank(str));
  }








  public String replaceBlank(String str){
    if (str==null){
      throw new IllegalArgumentException();
    }
    StringBuilder result=new StringBuilder();
    for(int i=0;i<str.length();i++){
      char c=str.charAt(i);
      if (String.valueOf(c).equals(" ")){
        result.append("空格");
      }else{
        result.append(c);
      }
    }
    return result.toString();
  }

}
